<?php
/* 
 *  
 */
$email=trim($_REQUEST['email']);
$password=trim($_REQUEST['password']);//提取数据库数据
require 'dbcon.php';
$sql="select * from users where email='{$email}'"; //提取表里邮箱
$result=$db->query($sql);
$num=$result->num_rows;
setcookie("email",$email);
if ($num==1)
{
    $row=$result->fetch_array();
    if ($password==$row['password'])
    {
       session_start();
       $_SESSION['userinfo']=array(//储存数据
           'id'=>$row['id'],
           'email'=>$row['email'],
           'nickname'=>$row['nickname'],
           'avatar'=>$row['avatar']
       );       
        header("Location:index.php");
    }
    else
    {
        header("Location:login.php?error=2");
    }
}
else
{
   header("Location:login.php?error=1");
}
